#include "list.h"
#include <stdlib.h>

struct test_list {
	struct list_head list;
	int data;
};	

void show_list(struct list_head *header)
{
	struct test_list *pos;

	printf("LIST: ");
	list_for_each_entry(pos, header, list){
		printf("%d ", pos->data);
	}
	printf("\n");
}

int main()
{
	struct list_head header;
	struct test_list *temp, *pos;
	int loop;

	INIT_LIST_HEAD(&header);

	/*add 1,2,3*/
	for (loop = 1; loop < 4; loop++) {
		temp = (struct test_list *)malloc(sizeof(struct test_list));
		temp->data = loop;
		list_add_tail(&temp->list, &header);
		show_list(&header);
	}
	/*remove 2*/
	list_for_each_entry(pos, &header, list) {
		if (pos->data == 2)
			__list_del(pos->list.prev, pos->list.next);
	}
	show_list(&header);

	exit(0);
}
